import http from '@/utils/http'; 
import qs from 'qs';

// 用户个人订单列表接口
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getUserOrderAPI(userId:any){  
    return http({  
        url:"/pet-adopt/user/order",  
        params:{  
            userId  
        }  
    })  
} 

// 用户发布的宠物列表接口
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function getUserPostPetsAPI(id: any){
    return http({
        url:"/pet-adopt/user/pet-list",
        params:{
            id
        }
    })
}

// 领养申请列表接口-领养申请页面
export function getAdoptApplicationAPI(userId){
    return http({
        url:"/pet-adopt/user/applications",
        params:{
            userId
        }
    })
}

// 领养申请通过接口-领养申请页面
export function AdoptApplicationYesAPI(id){
    return http({
        url:`/pet-adopt/pass-application/${id}`,
        method:"post"
    })
}
// 领养申请不通过接口-领养申请页面
export function AdoptApplicationNoAPI(id){
    return http({
        url:`/pet-adopt/refuse-application/${id}`,
        method:"post"
    })
}

// 用户争议订单列表
export function getDisputeOrderListAPI(userId){
    return http({
        url:"/pet-adopt/disputes/user",
        params:{
            userId
        }
    })

}

// 个人订单列表-我的领养-我购买的宠物
export function getUserAdoptPetListAPI(userId){
    return http({  
        url:"/pet-adopt/user/order",  
        params:{  
            userId,
            type:"adopter"
        }  
    })  
}

// 个人订单列表-我发布的-我卖出的宠物
export function getUserPublishPetListAPI(userId){
    return http({  
        url:"/pet-adopt/user/order",  
        params:{  
            userId,
            type:"publisher"
        }  
    })  
}

// 取消订单接口-id为orderID
export function postCancleOrderAPI(id){
    return http({
        url:`/pet-adopt/cancel-order/${id}`,
        method:"post"
    })
}

// 订单完成接口-确认收货
export function postConfirmGoodsAPI(id){
    return http({
        url:`/pet-adopt/complete/${id}`,
        method:"post"
    })
}

// 用户对订单发起疑问接口
export function postQuestionOrderAPI(disputerId,form){
    return http({
        url:"/pet-adopt/dispute/submit",
        method:"post",
        params:{
            disputerId
        },
        data:form
    })
}

// 发货接口
export function putSendAPI(orderId,deliveryNum){
    return http({
        url:"/pet-adopt/order-deliver",
        method:"put",
        params:{
            orderId,
            deliveryNum
        }
    })
}

// 注册接口
export function postRegisterAPI(form){
    return http({
        url:"/pet-adopt/auth/register",
        method:"post",
        data:form
    })
}

// 修改用户信息接口
export function postupdateUserInfo(userInfo){
    return http({
        url:"/pet-adopt/updateUserInfo",
        method:"post",
        data:userInfo
    })
}


// 登录接口
export function postLogin(form) {
  return http({
    url: "/pet-adopt/auth/login",
    method: "post",
    // 添加请求头
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    // 将数据序列化为表单格式
    data: qs.stringify(form)
  });
}

// 充值接口
// 修改用户信息接口
export function postRecharge(data){
    return http({
        url:"/pet-adopt/updateUserInfo",
        method:"post",
        data:data
    })
}


// 获取用户详细信息接口
export function getUserInfoAPI(userid){
    return http({
        url:"/pet-adopt/user",
        params:{
            userid
        }
    })
}